package com.xxgc.aop.spring;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.stereotype.Component;

@Component
public class UserEnhanceSpring {
    public void before(){
        System.out.println("前置增强");
    }
    public void afterReturning(){
        System.out.println("后置增强");
    }

    public void after(){
        System.out.println("最终");
    }

    //环绕执行
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("前置增强");
        //执行目标方法
        Object proceed = pjp.proceed();
        System.out.println("后置增强");
        return proceed;
    }

    public void throwing(){
        System.out.println("异常了");
    }
}
